package edu.kaist.cs408.pof.backend.service;

import edu.kaist.cs408.pof.backend.dao.DishDaoImpl;
import edu.kaist.cs408.pof.backend.dao.RestaurantDaoImpl;
import edu.kaist.cs408.pof.backend.dao.TalkDaoImpl;
import edu.kaist.cs408.pof.backend.dao.UserDaoImpl;
import edu.kaist.cs408.pof.common.model.DishVo;
import edu.kaist.cs408.pof.common.model.TalkVo;
import edu.kaist.cs408.pof.common.service.DishSvc;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;

/**
 * Created with IntelliJ IDEA.
 * User: duyleekun
 * Date: 5/9/12
 * Time: 7:54 PM
 * To change this template use File | Settings | File Templates.
 */

@Configurable
public class DishSvcImpl implements DishSvc {

	@Autowired(required = true)
	RestaurantDaoImpl restaurantDao;

	@Autowired(required = true)
	UserDaoImpl userDao;

	@Autowired(required = true)
	DishDaoImpl dishDao;

	@Autowired(required = true)
	TalkDaoImpl talkDao;


	@Override
	public DishVo rate(ObjectId dish, int score) {
		return dishDao.rate(dish, score);
	}

	@Override
	public DishVo postTalk(ObjectId dish, ObjectId user, TalkVo talk) {
		talk = talkDao.createTalk(talk);
		talkDao.setTalk(talk.getMid(), user, null, dish);
		return dishDao.get(dish);
	}


}
